<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./vue/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <p>调用计算属性msg:{{ msg }}</p>
      <p>调用计算属性info:{{ info }}</p>
      <p>调用data arr:{{ arr }}</p>
      <input type="text" v-model="arr[0]" />
      <hr />
      <test-comp></test-comp>
      <hr />
    </div>
    <script>
      // Vue.mixin(options)
      // options 就是vue组件创建时的配置选项
      // 为组件提供统一的配置=>但不会跨组件进行数据共享=>仅用于初始数据
      Vue.mixin({
        data() {
          return {
            arr: [1, 2, 3, 4],
          };
        },
        computed: {
          info() {
            return "info";
          },
        },
      });

      Vue.component("test-comp", {
        template: "<div>{{ arr }}</div>",
      });

      new Vue({
        el: "#app",
        computed: {
          msg() {
            return "计算属性msg";
          },
        },
      });
    </script>
  </body>
</html>
